import java.util.Random;

/**
 * 继承Thread，重写run方法来实现多线程
 */
public class MyThread extends Thread{
    @Override
    public void run() {
        //这里面写业务逻辑的
        Random random=new Random();
        while(true){
            System.out.println(Thread.currentThread().getName());
            try {
                Thread.sleep(random.nextInt(10));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
